extends NodeState

@export var player: Player



func _on_process(_delta : float) -> void:
	process_punch_coillder()



func _on_enter() -> void:
	process_animation()

	# 进入状态时打开监听，允许发生碰撞
	player.damageEmitter.monitoring = true


func _on_exit() -> void:
	# 退出状态时关闭监听，停止发生碰撞
	player.damageEmitter.monitoring = false


func process_animation():
	player.animationPlayer.play(Player.ANIMATION_PUNCH_ALT)


func process_punch_coillder():
	var orientation = player.character_orientation()
	if orientation == 1:
		player.damageEmitter.scale.x = 1
	elif orientation == -1:
		player.damageEmitter.scale.x = -1


func on_punch_alt_animation_finished():
	if player.inputManager.is_movement_input():
		transition_state(Player.STATE_WALK)
		return
	transition_state(Player.STATE_IDLE)
